package com.huaqin.punan.anim;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {

	private Button mybtn;
	private TextView txtview;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		txtview = (TextView) findViewById(R.id.mytext);
		
		mybtn = (Button)findViewById(R.id.mybtn);
		mybtn.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				
				UpdateViewContent();
				
			}});
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	public void UpdateViewContent() {
		
		txtview.setText("This is a test message");
		//txtview.setAnimation(AnimationUtils.loadAnimation(MainActivity.this,R.anim.push_left_in));
		
		Animation mAnimation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.push_left_in);
		//txtview.setAnimation(mAnimation);
		txtview.startAnimation(mAnimation);
		
	}
}
